//
//  ShareView.m
//  easyTaxi
//
//  Created by ellenpage on 13-3-27.
//  Copyright (c) 2013年 ellenpage. All rights reserved.
//

#import "ShareView.h"

@interface ShareView ()

- (IBAction)goBack;

- (IBAction)addPeople;

@end

@implementation ShareView


#pragma mark - System Function - 系统函数

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}


- (IBAction)goBack
{
    self.view.hidden = YES;
}

- (IBAction)addPeople
{
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    [self presentModalViewController:picker animated:YES];
}

#pragma mark - AddressBookView Delegate - 地址簿代理

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
    [peoplePicker dismissModalViewControllerAnimated:YES];
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
//    //获取联系人姓名
// name.text = (NSString*)ABRecordCopyCompositeName(person);
//    
//    
////获取联系人电话
//    
//    　ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
//    
//     NSMutableArray *phones = [[NSMutableArray alloc] init];
//    
//    int i;
//    
//    for (i = 0; i < ABMultiValueGetCount(phoneMulti); i++)
//    {
//        
//        　NSString *aPhone = [(NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, i) autorelease];
//        
//        　NSString *aLabel = [(NSString*)ABMultiValueCopyLabelAtIndex(phoneMulti, i) autorelease];
//        
//        　NSLog(@"PhoneLabel:%@ Phone#:%@",aLabel,aPhone);
//        
//        　if([aLabel isEqualToString:@"_$!<Mobile>!$_"])
//            
//            　　{
//                　　　　[phones addObject:aPhone];
//                　　}
//        　}
//    
//    phoneNo.text=@"";
//    
//    if([phones count]>0)
//        
//    {
//        　NSString *mobileNo = [phones objectAtIndex:0];
//        　phoneNo.text = mobileNo;
//        　//NSLog(mobileNo);
//        
//    }
//    //获取联系人邮箱
//    ABMutableMultiValueRef emailMulti = ABRecordCopyValue(person, kABPersonEmailProperty);
//    
//    NSMutableArray *emails = [[NSMutableArray alloc] init];
//    
//    for (i = 0;i < ABMultiValueGetCount(emailMulti); i++)
//        
//    {
//        　　NSString *emailAdress = [(NSString*)ABMultiValueCopyValueAtIndex(emailMulti, i) autorelease];
//        
//        　　[emails addObject:emailAdress];
//    }
//    
//    email.text=@"";
//    
//    if([emails count]>0)
//        
//    {
//        　　NSString *emailFirst=[emails objectAtIndex:0];
//        　　email.text = emailFirst;
//        　　//NSLog(emailFirst);
//    }
//    
//    [peoplePicker dismissModalViewControllerAnimated:YES];
    
    return NO;
}

@end
